<template>
  <div>
    <!-- <img :src="imgAddress" alt="" /> -->
    <iframe :src="imgAddress" frameborder="0"></iframe>
  </div>
</template>

<script>
import {
  getQRCodeKey,
  getQRCode,
} from "../../../netWork/easeRequest/easeLoginServer";

export default {
  name: "LoginWithRQCode",

  data() {
    return {
      imgAddress: "",
      unikey: "",
    };
  },

  created() {
    /**
     * 二维码获取分三步
     */
    this.$message({
      type: 'warning',
      message: '由于网易云接口问题，扫码登录暂不提供给开发者使用'
    })
    // 1. 获取二维码所需要的key
    // this.getQRCodeKey()
  },

  mounted() {},

  methods: {
    // 获取二维码所需要的key
    getQRCodeKey: function () {
      let that = this
      getQRCodeKey().then((res) => {
        if (res.data.code == "200") {
          // that.unikey = res.data.data.unikey
          // console.log('二维码的key', res.data.data.unikey)

          // 2. 根据key获取二维码图片
          that.getQRCodeUrl(res.data.data.unikey)
        } else {
          that.$message({
            type: "error",
            message: "erroe 1. 获取二维码失败，请检查您的网络",
          })
        }
      })
    },

    //  根据key获取二维码图片
    getQRCodeUrl: function (key) {
      let that = this
      getQRCode(key)
      .then((res) => {
        console.log("获取二维码图片", res)
        if(res.data.code == '200') {
          that.imgAddress = res.data.data.qrurl
        } else {
          that.$message({
            type: "error",
            message: "erroe 2. 获取二维码失败，请检查您的网络",
          })
        }
      })
    },


  },
}

</script>

<style lang="less" scoped>
</style>